// pages/smart/index.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
		tabindex:0,
        banner: "/images/smart1.jpg",
		tabs:["进行中","已过期","即将开放"],
		list:"",
		smartlist: [
			{ status: "进行中", img: "/images/smart3.jpg", name: "盛世中心奔驰Smart-0元抽", location: "福建厦门", date: "2018.12.23", looknum: "223", joinnum: "2434" },
			{ status: "进行中", img: "/images/smart3.jpg", name: "盛世中心奔驰Smart-0元抽", location: "福建厦门", date: "2018.12.23", looknum: "223", joinnum: "2434" },
			{ status: "已过期", img: "/images/smart3.jpg", name: "盛世中心奔驰Smart-0元抽", location: "福建厦门", date: "2018.12.23", looknum: "223" },
			{ status: "已过期", img: "/images/smart3.jpg", name: "盛世中心奔驰Smart-0元抽", location: "福建厦门", date: "2018.12.23", looknum: "223" },
			{ status: "即将开放", img: "/images/smart3.jpg", name: "盛世中心奔驰Smart-0元抽", location: "福建厦门", date: "2018.12.23", looknum: "223" },
		]
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
		var that=this
		var list = []
		var smartlist = that.data.smartlist
		for (let i = 0; i < smartlist.length; i++) {
			if (smartlist[i].status.toString() == that.data.tabs[that.data.tabindex].toString()) {
				list.push(smartlist[i])
			}
		}
		that.setData({
			list: list
		})
    },
	//切换状态
	bindTabs: function (e) {
		wx.showLoading()
		var that = this
		var smartlist = that.data.smartlist
		var list = []
		for (let i = 0; i < smartlist.length; i++) {
			if (smartlist[i].status == that.data.tabs[e.currentTarget.dataset.index]) {
				list.push(smartlist[i])
			}
		}
		that.setData({
			tabindex: e.currentTarget.dataset.index,
			list: list
		})
		wx.hideLoading()
	},
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    }
})